<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>FreeMarker</title>
    <link rel="stylesheet" href="/static/js/layui/css/layui.css">
</head>
<style>
    body {
        margin: 20px 0px 20px 20px;
    }
    .warning{
        color: #FD482C;
    }
</style>
<body>
<div class="layui-container">
    <div class="layui-row">
        <div class="layui-col-md12">
            <form class="layui-form" action="">

                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-md12">
                            <label class="layui-form-label"><span class="layui-badge-dot"></span>表名</label>
                            <div class="layui-input-block">
                                <input type="text" name="tableArr" disabled
                                       autocomplete="off" class="layui-input" value="${tables!}">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-md8">
                            <label class="layui-form-label"><span class="layui-badge-dot"></span>项目路径</label>
                            <div class="layui-input-block">
                                <input type="text" name="workPath" required lay-verify="required" placeholder="请输入项目路径"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-mid layui-word-aux"> 例: E:\test-workspaces\generator-code</div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-md3">
                            <label class="layui-form-label"><span class="layui-badge-dot"></span>生成类型</label>
                            <div class="layui-input-block">
                                <select name="type" lay-verify="required">
                                    <option value="jpa">jpa</option>
                                    <option value="plus">mybatis-plus</option>
                                    <option value="tk">tk.mybatis</option>
                                </select>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-md3">
                            <label class="layui-form-label"><span class="layui-badge-dot"></span>继承基类</label>
                            <div class="layui-input-block">
                                <select name="isExtends" lay-verify="required">
                                    <option value="true">是</option>
                                    <option value="false">否</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-col-md9">
                            <div class="layui-form-mid layui-word-aux">例: 继承BaseData BaseService BaseDao</div>
                        </div>
                    </div>
                </div>



                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-md5">
                            <label class="layui-form-label"><span class="layui-badge-dot"></span>实体路径</label>
                            <div class="layui-input-block">
                                <input type="text" name="entityPath" required lay-verify="required" placeholder="请输入实体路径"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-col-md7">
                            <div class="layui-form-mid layui-word-aux">例: com.example.tagsdemo.entity</div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-md5">
                            <label class="layui-form-label">类作者</label>
                            <div class="layui-input-block">
                                <input type="text" name="author" placeholder="zmj"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-md5">
                            <label class="layui-form-label">service路径</label>
                            <div class="layui-input-block">
                                <input type="text" name="servicePath" placeholder="不填则不生成"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-col-md7">
                            <div class="layui-form-mid layui-word-aux">例: 继承BaseData BaseService BaseDao</div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-row">
                        <div class="layui-col-md5">
                            <label class="layui-form-label">dao路径</label>
                            <div class="layui-input-block">
                                <input type="text" name="daoPath"  placeholder="不填则不生成"
                                       autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-col-md7">
                            <div class="layui-form-mid layui-word-aux">例: com.example.tagsdemo.dao</div>
                        </div>
                    </div>
                </div>

<#--                <div class="layui-form-item">-->
<#--                    <div class="layui-row">-->
<#--                        <div class="layui-col-md5">-->
<#--                            <label class="layui-form-label">xml路径</label>-->
<#--                            <div class="layui-input-block">-->
<#--                                <input type="text" name="xmlPath"  placeholder="不填则不生成"-->
<#--                                       autocomplete="off" class="layui-input">-->
<#--                            </div>-->
<#--                        </div>-->
<#--                        <div class="layui-col-md7">-->
<#--                            <div class="layui-form-mid layui-word-aux">例: 静态资源resources下 /xml 或 包路径 com.example.tagsdemo.xml</div>-->
<#--                        </div>-->
<#--                    </div>-->
<#--                </div>-->

                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="generator">确定生成</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="/static/js/jquery-3.4.1.js"></script>
<script src="/static/js/layui/layui.js"></script>
</body>
<script>
    $(function () {
        layui.use('layer', function () {
            var layer = layui.layer;
        });

        layui.use('form', function(){
            var form = layui.form;

            //监听提交
            form.on('submit(generator)', function(data){
                layer.msg(JSON.stringify(data.field));

                $.ajax({
                    //请求方式
                    type : "POST",
                    url : "/entity/create",
                    contentType: 'application/json',
                    data : JSON.stringify(data.field),
                    dataType: 'json',
                    async: true,
                    success : function(result) {
                        if (result.code == 200 || result.code == '200') {
                                layer.msg("数据实体类生成成功",{icon:1,time:3000,shade:0.4},function() {
                            })
                        }
                    },
                    error : function(e){
                        console.log(e);
                    }
                });

                return false;
            });
        });
    })
</script>
</html>